<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libcoap: Block Transfer</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">libcoap<span id="projectnumber">&#160;4.2.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__block.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">Block Transfer</div></div>
</div><!--header-->
<div class="contents">

<p>API functions for handling PDUs using CoAP BLOCK options.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structcoap__block__t.html">coap_block_t</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Structure of Block options.  <a href="structcoap__block__t.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga1a064effcefd02b9e5c8f99b297c0edc" id="r_ga1a064effcefd02b9e5c8f99b297c0edc"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__block.html#ga1a064effcefd02b9e5c8f99b297c0edc">COAP_MAX_BLOCK_SZX</a>&#160;&#160;&#160;6</td></tr>
<tr class="memdesc:ga1a064effcefd02b9e5c8f99b297c0edc"><td class="mdescLeft">&#160;</td><td class="mdescRight">The largest value for the SZX component in a Block option.  <br /></td></tr>
<tr class="separator:ga1a064effcefd02b9e5c8f99b297c0edc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad7d63d1ac6f4e326be162f5fb1ee48d9" id="r_gad7d63d1ac6f4e326be162f5fb1ee48d9"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__block.html#gad7d63d1ac6f4e326be162f5fb1ee48d9">COAP_OPT_BLOCK_LAST</a>(opt)&#160;&#160;&#160;  (<a class="el" href="group__opt__filter.html#gaac65919c93f7047b687d33af9672b3ea">coap_opt_length</a>(opt) ? (<a class="el" href="group__opt__filter.html#gaec4e944d39722779cac610ed22ee09db">coap_opt_value</a>(opt) + (<a class="el" href="group__opt__filter.html#gaac65919c93f7047b687d33af9672b3ea">coap_opt_length</a>(opt)-1)) : 0)</td></tr>
<tr class="memdesc:gad7d63d1ac6f4e326be162f5fb1ee48d9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the value of the least significant byte of a Block option <code>opt</code>.  <br /></td></tr>
<tr class="separator:gad7d63d1ac6f4e326be162f5fb1ee48d9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9e87e4bbd861945d9d1cc672c781662b" id="r_ga9e87e4bbd861945d9d1cc672c781662b"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__block.html#ga9e87e4bbd861945d9d1cc672c781662b">COAP_OPT_BLOCK_MORE</a>(opt)&#160;&#160;&#160;  (<a class="el" href="group__opt__filter.html#gaac65919c93f7047b687d33af9672b3ea">coap_opt_length</a>(opt) ? (*<a class="el" href="group__block.html#gad7d63d1ac6f4e326be162f5fb1ee48d9">COAP_OPT_BLOCK_LAST</a>(opt) &amp; 0x08) : 0)</td></tr>
<tr class="memdesc:ga9e87e4bbd861945d9d1cc672c781662b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the value of the More-bit of a Block option <code>opt</code>.  <br /></td></tr>
<tr class="separator:ga9e87e4bbd861945d9d1cc672c781662b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3b14a086973dff06815f999b6c873429" id="r_ga3b14a086973dff06815f999b6c873429"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__block.html#ga3b14a086973dff06815f999b6c873429">COAP_OPT_BLOCK_SZX</a>(opt)&#160;&#160;&#160;  (<a class="el" href="group__opt__filter.html#gaac65919c93f7047b687d33af9672b3ea">coap_opt_length</a>(opt) ? (*<a class="el" href="group__block.html#gad7d63d1ac6f4e326be162f5fb1ee48d9">COAP_OPT_BLOCK_LAST</a>(opt) &amp; 0x07) : 0)</td></tr>
<tr class="memdesc:ga3b14a086973dff06815f999b6c873429"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the value of the SZX-field of a Block option <code>opt</code>.  <br /></td></tr>
<tr class="separator:ga3b14a086973dff06815f999b6c873429"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gaac6c90297abc6e2da80a6212b0d10e99" id="r_gaac6c90297abc6e2da80a6212b0d10e99"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__block.html#gaac6c90297abc6e2da80a6212b0d10e99">coap_opt_block_num</a> (const <a class="el" href="option_8h.html#a963ad4994625360a5ac70d9df2ab5412">coap_opt_t</a> *block_opt)</td></tr>
<tr class="memdesc:gaac6c90297abc6e2da80a6212b0d10e99"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the value of field <code>num</code> in the given block option <code>block_opt</code>.  <br /></td></tr>
<tr class="separator:gaac6c90297abc6e2da80a6212b0d10e99"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa67d14fa889f79afee9762dab7fc83e4" id="r_gaa67d14fa889f79afee9762dab7fc83e4"><td class="memItemLeft" align="right" valign="top"><a class="el" href="libcoap_8h.html#a58b4446dccd0b8c21b3532ef6b77a57d">COAP_STATIC_INLINE</a> int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__block.html#gaa67d14fa889f79afee9762dab7fc83e4">coap_more_blocks</a> (size_t data_len, unsigned int num, uint16_t szx)</td></tr>
<tr class="memdesc:gaa67d14fa889f79afee9762dab7fc83e4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks if more than <code>num</code> blocks are required to deliver <code>data_len</code> bytes of data for a block size of 1 &lt;&lt; (<code>szx</code> + 4).  <br /></td></tr>
<tr class="separator:gaa67d14fa889f79afee9762dab7fc83e4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga714d943bd85123de1b8b6f86ec204a69" id="r_ga714d943bd85123de1b8b6f86ec204a69"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__block.html#ga714d943bd85123de1b8b6f86ec204a69">coap_get_block</a> (<a class="el" href="structcoap__pdu__t.html">coap_pdu_t</a> *pdu, uint16_t type, <a class="el" href="structcoap__block__t.html">coap_block_t</a> *block)</td></tr>
<tr class="memdesc:ga714d943bd85123de1b8b6f86ec204a69"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes <code>block</code> from <code>pdu</code>.  <br /></td></tr>
<tr class="separator:ga714d943bd85123de1b8b6f86ec204a69"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0462e5c93460d2df1c60611188192524" id="r_ga0462e5c93460d2df1c60611188192524"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__block.html#ga0462e5c93460d2df1c60611188192524">coap_write_block_opt</a> (<a class="el" href="structcoap__block__t.html">coap_block_t</a> *block, uint16_t type, <a class="el" href="structcoap__pdu__t.html">coap_pdu_t</a> *pdu, size_t data_length)</td></tr>
<tr class="memdesc:ga0462e5c93460d2df1c60611188192524"><td class="mdescLeft">&#160;</td><td class="mdescRight">Writes a block option of type <code>type</code> to message <code>pdu</code>.  <br /></td></tr>
<tr class="separator:ga0462e5c93460d2df1c60611188192524"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0a90438f60d08abd88da955ec895cedb" id="r_ga0a90438f60d08abd88da955ec895cedb"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__block.html#ga0a90438f60d08abd88da955ec895cedb">coap_add_block</a> (<a class="el" href="structcoap__pdu__t.html">coap_pdu_t</a> *pdu, unsigned int len, const <a class="el" href="uthash_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *data, unsigned int block_num, unsigned char block_szx)</td></tr>
<tr class="memdesc:ga0a90438f60d08abd88da955ec895cedb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Adds the <code>block_num</code> block of size 1 &lt;&lt; (<code>block_szx</code> + 4) from source <code>data</code> to <code>pdu</code>.  <br /></td></tr>
<tr class="separator:ga0a90438f60d08abd88da955ec895cedb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga38c1e9829062e3e2ce621641f1ae59c5" id="r_ga38c1e9829062e3e2ce621641f1ae59c5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__block.html#ga38c1e9829062e3e2ce621641f1ae59c5">coap_add_data_blocked_response</a> (struct <a class="el" href="structcoap__resource__t.html">coap_resource_t</a> *resource, struct <a class="el" href="structcoap__session__t.html">coap_session_t</a> *session, <a class="el" href="structcoap__pdu__t.html">coap_pdu_t</a> *request, <a class="el" href="structcoap__pdu__t.html">coap_pdu_t</a> *response, const <a class="el" href="structcoap__binary__t.html">coap_binary_t</a> *token, uint16_t media_type, int maxage, size_t length, const <a class="el" href="uthash_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *data)</td></tr>
<tr class="memdesc:ga38c1e9829062e3e2ce621641f1ae59c5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Adds the appropriate part of <code>data</code> to the <code>response</code> pdu.  <br /></td></tr>
<tr class="separator:ga38c1e9829062e3e2ce621641f1ae59c5"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>API functions for handling PDUs using CoAP BLOCK options. </p>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a id="ga1a064effcefd02b9e5c8f99b297c0edc" name="ga1a064effcefd02b9e5c8f99b297c0edc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga1a064effcefd02b9e5c8f99b297c0edc">&#9670;&#160;</a></span>COAP_MAX_BLOCK_SZX</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define COAP_MAX_BLOCK_SZX&#160;&#160;&#160;6</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>The largest value for the SZX component in a Block option. </p>

<p class="definition">Definition at line <a class="el" href="block_8h_source.html#l00030">30</a> of file <a class="el" href="block_8h_source.html">block.h</a>.</p>

</div>
</div>
<a id="gad7d63d1ac6f4e326be162f5fb1ee48d9" name="gad7d63d1ac6f4e326be162f5fb1ee48d9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad7d63d1ac6f4e326be162f5fb1ee48d9">&#9670;&#160;</a></span>COAP_OPT_BLOCK_LAST</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define COAP_OPT_BLOCK_LAST</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">opt</td><td>)</td>
          <td>&#160;&#160;&#160;  (<a class="el" href="group__opt__filter.html#gaac65919c93f7047b687d33af9672b3ea">coap_opt_length</a>(opt) ? (<a class="el" href="group__opt__filter.html#gaec4e944d39722779cac610ed22ee09db">coap_opt_value</a>(opt) + (<a class="el" href="group__opt__filter.html#gaac65919c93f7047b687d33af9672b3ea">coap_opt_length</a>(opt)-1)) : 0)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the value of the least significant byte of a Block option <code>opt</code>. </p>
<p>For zero-length options (i.e. num == m == szx == 0), COAP_OPT_BLOCK_LAST returns <code>NULL</code>. </p>

<p class="definition">Definition at line <a class="el" href="block_8h_source.html#l00047">47</a> of file <a class="el" href="block_8h_source.html">block.h</a>.</p>

</div>
</div>
<a id="ga9e87e4bbd861945d9d1cc672c781662b" name="ga9e87e4bbd861945d9d1cc672c781662b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9e87e4bbd861945d9d1cc672c781662b">&#9670;&#160;</a></span>COAP_OPT_BLOCK_MORE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define COAP_OPT_BLOCK_MORE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">opt</td><td>)</td>
          <td>&#160;&#160;&#160;  (<a class="el" href="group__opt__filter.html#gaac65919c93f7047b687d33af9672b3ea">coap_opt_length</a>(opt) ? (*<a class="el" href="group__block.html#gad7d63d1ac6f4e326be162f5fb1ee48d9">COAP_OPT_BLOCK_LAST</a>(opt) &amp; 0x08) : 0)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the value of the More-bit of a Block option <code>opt</code>. </p>

<p class="definition">Definition at line <a class="el" href="block_8h_source.html#l00051">51</a> of file <a class="el" href="block_8h_source.html">block.h</a>.</p>

</div>
</div>
<a id="ga3b14a086973dff06815f999b6c873429" name="ga3b14a086973dff06815f999b6c873429"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3b14a086973dff06815f999b6c873429">&#9670;&#160;</a></span>COAP_OPT_BLOCK_SZX</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define COAP_OPT_BLOCK_SZX</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">opt</td><td>)</td>
          <td>&#160;&#160;&#160;  (<a class="el" href="group__opt__filter.html#gaac65919c93f7047b687d33af9672b3ea">coap_opt_length</a>(opt) ? (*<a class="el" href="group__block.html#gad7d63d1ac6f4e326be162f5fb1ee48d9">COAP_OPT_BLOCK_LAST</a>(opt) &amp; 0x07) : 0)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the value of the SZX-field of a Block option <code>opt</code>. </p>

<p class="definition">Definition at line <a class="el" href="block_8h_source.html#l00055">55</a> of file <a class="el" href="block_8h_source.html">block.h</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga0a90438f60d08abd88da955ec895cedb" name="ga0a90438f60d08abd88da955ec895cedb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga0a90438f60d08abd88da955ec895cedb">&#9670;&#160;</a></span>coap_add_block()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int coap_add_block </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structcoap__pdu__t.html">coap_pdu_t</a> *&#160;</td>
          <td class="paramname"><em>pdu</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="uthash_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>block_num</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>block_szx</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Adds the <code>block_num</code> block of size 1 &lt;&lt; (<code>block_szx</code> + 4) from source <code>data</code> to <code>pdu</code>. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pdu</td><td>The message to add the block. </td></tr>
    <tr><td class="paramname">len</td><td>The length of <code>data</code>. </td></tr>
    <tr><td class="paramname">data</td><td>The source data to fill the block with. </td></tr>
    <tr><td class="paramname">block_num</td><td>The actual block number. </td></tr>
    <tr><td class="paramname">block_szx</td><td>Encoded size of block <code>block_number</code>.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>1</code> on success, <code>0</code> otherwise. </dd></dl>

<p class="definition">Definition at line <a class="el" href="block_8c_source.html#l00135">135</a> of file <a class="el" href="block_8c_source.html">block.c</a>.</p>

</div>
</div>
<a id="ga38c1e9829062e3e2ce621641f1ae59c5" name="ga38c1e9829062e3e2ce621641f1ae59c5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga38c1e9829062e3e2ce621641f1ae59c5">&#9670;&#160;</a></span>coap_add_data_blocked_response()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void coap_add_data_blocked_response </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structcoap__resource__t.html">coap_resource_t</a> *&#160;</td>
          <td class="paramname"><em>resource</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct <a class="el" href="structcoap__session__t.html">coap_session_t</a> *&#160;</td>
          <td class="paramname"><em>session</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structcoap__pdu__t.html">coap_pdu_t</a> *&#160;</td>
          <td class="paramname"><em>request</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structcoap__pdu__t.html">coap_pdu_t</a> *&#160;</td>
          <td class="paramname"><em>response</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structcoap__binary__t.html">coap_binary_t</a> *&#160;</td>
          <td class="paramname"><em>token</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>media_type</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>maxage</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="uthash_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> *&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Adds the appropriate part of <code>data</code> to the <code>response</code> pdu. </p>
<p>If blocks are required, then the appropriate block will be added to the PDU and sent. Adds a ETAG option that is the hash of the entire data if the data is to be split into blocks Used by a GET request handler.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">resource</td><td>The resource the data is associated with. </td></tr>
    <tr><td class="paramname">session</td><td>The coap session. </td></tr>
    <tr><td class="paramname">request</td><td>The requesting pdu. </td></tr>
    <tr><td class="paramname">response</td><td>The response pdu. </td></tr>
    <tr><td class="paramname">token</td><td>The token taken from the (original) requesting pdu. </td></tr>
    <tr><td class="paramname">media_type</td><td>The format of the data. </td></tr>
    <tr><td class="paramname">maxage</td><td>The maxmimum life of the data. If <code>-1</code>, then there is no maxage. </td></tr>
    <tr><td class="paramname">length</td><td>The total length of the data. </td></tr>
    <tr><td class="paramname">data</td><td>The entire data block to transmit. </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="block_8c_source.html#l00152">152</a> of file <a class="el" href="block_8c_source.html">block.c</a>.</p>

</div>
</div>
<a id="ga714d943bd85123de1b8b6f86ec204a69" name="ga714d943bd85123de1b8b6f86ec204a69"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga714d943bd85123de1b8b6f86ec204a69">&#9670;&#160;</a></span>coap_get_block()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int coap_get_block </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structcoap__pdu__t.html">coap_pdu_t</a> *&#160;</td>
          <td class="paramname"><em>pdu</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>type</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structcoap__block__t.html">coap_block_t</a> *&#160;</td>
          <td class="paramname"><em>block</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initializes <code>block</code> from <code>pdu</code>. </p>
<p><code>type</code> must be either COAP_OPTION_BLOCK1 or COAP_OPTION_BLOCK2. When option <code>type</code> was found in <code>pdu</code>, <code>block</code> is initialized with values from this option and the function returns the value <code>1</code>. Otherwise, <code>0</code> is returned.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">pdu</td><td>The pdu to search for option <code>type</code>. </td></tr>
    <tr><td class="paramname">type</td><td>The option to search for (must be COAP_OPTION_BLOCK1 or COAP_OPTION_BLOCK2). </td></tr>
    <tr><td class="paramname">block</td><td>The block structure to initilize.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>1</code> on success, <code>0</code> otherwise. </dd></dl>

<p class="definition">Definition at line <a class="el" href="block_8c_source.html#l00046">46</a> of file <a class="el" href="block_8c_source.html">block.c</a>.</p>

</div>
</div>
<a id="gaa67d14fa889f79afee9762dab7fc83e4" name="gaa67d14fa889f79afee9762dab7fc83e4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa67d14fa889f79afee9762dab7fc83e4">&#9670;&#160;</a></span>coap_more_blocks()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="libcoap_8h.html#a58b4446dccd0b8c21b3532ef6b77a57d">COAP_STATIC_INLINE</a> int coap_more_blocks </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>data_len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>num</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>szx</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Checks if more than <code>num</code> blocks are required to deliver <code>data_len</code> bytes of data for a block size of 1 &lt;&lt; (<code>szx</code> + 4). </p>

<p class="definition">Definition at line <a class="el" href="block_8h_source.html#l00068">68</a> of file <a class="el" href="block_8h_source.html">block.h</a>.</p>

</div>
</div>
<a id="gaac6c90297abc6e2da80a6212b0d10e99" name="gaac6c90297abc6e2da80a6212b0d10e99"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaac6c90297abc6e2da80a6212b0d10e99">&#9670;&#160;</a></span>coap_opt_block_num()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned int coap_opt_block_num </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="option_8h.html#a963ad4994625360a5ac70d9df2ab5412">coap_opt_t</a> *&#160;</td>
          <td class="paramname"><em>block_opt</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the value of field <code>num</code> in the given block option <code>block_opt</code>. </p>

<p class="definition">Definition at line <a class="el" href="block_8c_source.html#l00027">27</a> of file <a class="el" href="block_8c_source.html">block.c</a>.</p>

</div>
</div>
<a id="ga0462e5c93460d2df1c60611188192524" name="ga0462e5c93460d2df1c60611188192524"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga0462e5c93460d2df1c60611188192524">&#9670;&#160;</a></span>coap_write_block_opt()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int coap_write_block_opt </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structcoap__block__t.html">coap_block_t</a> *&#160;</td>
          <td class="paramname"><em>block</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>type</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structcoap__pdu__t.html">coap_pdu_t</a> *&#160;</td>
          <td class="paramname"><em>pdu</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>data_length</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Writes a block option of type <code>type</code> to message <code>pdu</code>. </p>
<p>If the requested block size is too large to fit in <code>pdu</code>, it is reduced accordingly. An exception is made for the final block when less space is required. The actual length of the resource is specified in <code>data_length</code>.</p>
<p>This function may change *block to reflect the values written to <code>pdu</code>. As the function takes into consideration the remaining space <code>pdu</code>, no more options should be added after <a class="el" href="group__block.html#ga0462e5c93460d2df1c60611188192524" title="Writes a block option of type type to message pdu.">coap_write_block_opt()</a> has returned.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">block</td><td>The block structure to use. On return, this object is updated according to the values that have been written to <code>pdu</code>. </td></tr>
    <tr><td class="paramname">type</td><td>COAP_OPTION_BLOCK1 or COAP_OPTION_BLOCK2. </td></tr>
    <tr><td class="paramname">pdu</td><td>The message where the block option should be written. </td></tr>
    <tr><td class="paramname">data_length</td><td>The length of the actual data that will be added the <code>pdu</code> by calling <a class="el" href="group__block.html#ga0a90438f60d08abd88da955ec895cedb" title="Adds the block_num block of size 1 &lt;&lt; (block_szx + 4) from source data to pdu.">coap_add_block()</a>.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>1</code> on success, or a negative value on error. </dd></dl>

<p class="definition">Definition at line <a class="el" href="block_8c_source.html#l00074">74</a> of file <a class="el" href="block_8c_source.html">block.c</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Fri Dec 27 2024 09:57:44 for libcoap by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8 </li>
  </ul>
</div>
</body>
</html>
